<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>点击按钮，锁住屏幕</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script>
<style>
 
/*弹出层*/
#box_bg{width:100%; background:#CCCCCC; position:absolute; top:0%; left:0%; z-index:10; display:none;}
 
#login{width:330px; position:absolute; left:50%;top:50%;margin-left:-165px; z-index:200;border:10px solid #ccd8dd;padding:20px;background:#fff;position:relative;font-size:14px;zoom:1;}
 
</style>
 
<script type="text/javascript">
$(document).ready(function(){
$("#ceng").click(function(){
var h = $(document).height();
var h1 = $(document).scrollTop();
var h2 = $('#login').css('margin-top');
 
h2 = parseFloat(h2);
 
$('#box_bg').css({display:'block',opacity:0.5,height:h+'px'});
 
$('#login').css({display:'block'});
 
$('#login').css({display:'block',marginTop:(h2+h1)+'px'});
 
});
 
 
$("#close_login").click(function(){
 
$("#login").hide();
 
$("#box_bg").hide();
 
$("#login").css({marginTop:'px'});
 
});
 
});
</script>
</head>
<body>
<span id="ceng">点击这里弹出层</span>
 
<br/>这是个有趣的测试
 
<div class="wrap" id="login" style="display:none;">
<div class="float_div" style="width:330px;">
 
<button id="close_login">点击关闭。</button>
 
 
</div>
 
</div>
 
<div id="box_bg">11111111</div>
</body>
</html>